# Contributor: George Hopkins <george-hopkins@null.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=imhex
pkgver=1.33.2
pkgrel=1
pkgdesc="Hex editor for reverse engineers and programmers"
url="https://github.com/WerWolv/ImHex"
# armhf, armv7, x86: 32-bit not supported
arch="all !armhf !armv7 !x86"
license="GPL-2.0-or-later"
options="!check" # No testsuite
makedepends="
	capstone-dev
	cmake
	curl-dev
	file-dev
	fmt-dev
	freetype-dev
	glfw-dev
	glm-dev
	gtk+3.0-dev
	libarchive-dev
	llvm-dev
	llvm-gtest
	llvm-static
	mbedtls-dev
	nlohmann-json
	openssl-dev
	python3-dev
	samurai
	yara-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/WerWolv/ImHex/releases/download/v$pkgver/Full.Sources.tar.gz
	$pkgname-patterns-$pkgver.tar.gz::https://github.com/WerWolv/ImHex-Patterns/archive/refs/tags/ImHex-v$pkgver.tar.gz
	fix-lfs64.patch
	no-werror.patch
	"
builddir="$srcdir/ImHex"

prepare() {
	default_prepare

	mv -v "$srcdir"/ImHex-Patterns-ImHex-v$pkgver/ \
		ImHex-Patterns
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_CAPSTONE=ON \
		-DUSE_SYSTEM_NLOHMANN_JSON=ON \
		-DUSE_SYSTEM_FMT=ON \
		-DUSE_SYSTEM_LLVM=ON \
		-DUSE_SYSTEM_YARA=ON \
		-DIMHEX_DISABLE_STACKTRACE=ON \
		-DIMHEX_IGNORE_BAD_CLONE=ON \
		-DIMHEX_OFFLINE_BUILD=ON \
		-DIMHEX_STRIP_RELEASE=OFF \
		-DIMHEX_USE_GTK_FILE_PICKER=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	cd "$pkgdir"
	rm -rf usr/share/imhex/sdk
	rm usr/bin/imhex-updater
}

sha512sums="
393719670019d7fa11d3f67a6b5ef8d2ae75812078a8beaba6b9b3091a283fc9790161c018073933c1b4a8cbcedf8ff7534aacac20ef4d210f10632db6e487ec  imhex-1.33.2.tar.gz
e6b6409b5f5e64de339f5a493c33c06e6033c8f4a1fc594f8f23d3ecd9b6d8a66e712e06649f0312e55860a682e532db000d1f1534d6fdd88181b6738c9201e0  imhex-patterns-1.33.2.tar.gz
e705ce53d0af206ae87b51f0978b2ce7529ceefa31049dc84ca6803e8f25101e6bde88b66fb2ae3fec16239f97bc2b3bc98ebbf6c2bfaa57eed89667af087adb  fix-lfs64.patch
7882b0cc1fe1c620de0757f1a2b5893b7ff395479aa870719e0662dc11625c2929e786412d9031df9653257e76edd0292a3d50492f072b2ab275e46e75c3e441  no-werror.patch
"
